package com.tianma315.admin.product.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.product.vo.RecallVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.product.dao.RecallDao;
import com.tianma315.admin.product.domain.RecallDO;
import com.tianma315.admin.product.service.RecallService;

import java.util.Date;
import java.util.List;

/**
 * 
 * <pre>
 * 召回信息
 * </pre>
 * <small> 2019-07-15 17:14:03 | wen</small>
 */
@Service
public class RecallServiceImpl extends CoreServiceImpl<RecallDao, RecallDO> implements RecallService {

    @Autowired
    private RecallDao recallDao;

    @Override
    public Page<RecallVO> getRecallPage(Integer pageNumber, Integer pageSize, RecallVO recallDO) {
        Page<RecallVO> page = new Page(pageNumber,pageSize);
        List<RecallVO> list = recallDao.getRecallPage(page,recallDO);
        page.setRecords(list);
        return page;
    }

    @Override
    public Boolean addRecall(RecallDO recallDO) {
        recallDO.setCreateDate(new Date());
        recallDO.setState(0);
        Boolean result = insert(recallDO);
        return result;
    }

    @Override
    public Boolean deleteRecall(Integer recallId) {
        RecallDO recallDO = new RecallDO();
        recallDO.setState(1);
        recallDO.setRecallId(recallId);
        Boolean result = updateById(recallDO);
        return result;
    }
}
